package com.neu.elm.controller;


import com.neu.elm.po.Orders;
import com.neu.elm.service.OrdersService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:csw
 * @Date: 9:16 2020/9/16
 */
@RestController
@RequestMapping("/OrdersController")
public class OrdersController {

    @Resource
    private OrdersService ordersService;

//http://localhost:8088/elm/OrdersController/createOrders?userId=123&businessId=10008&orderDate=2020-9-16&orderTotal=18.5&daId=1
    @RequestMapping("/createOrders")
    public int createOrders(Orders orders) throws Exception{
        return ordersService.createOrders(orders);
    }
//http://localhost:8088/elm/OrdersController/getOrdersById?orderId=1
    @RequestMapping("/getOrdersById")
    public Orders getOrdersById(Orders orders) throws Exception{
        return ordersService.getOrdersById(orders.getOrderId());
    }
//http://localhost:8088/elm/OrdersController/listOrdersByUserId?userId=123
    @RequestMapping("/listOrdersByUserId")
    public List<Orders> listOrdersByUserId(Orders orders) throws Exception{
        return ordersService.listOrdersByUserId(orders.getUserId());
    }
}
